package com.zhuiYun.project.api.order.mapper;

import com.zhuiYun.project.api.order.entity.Order;
import com.zhuiYun.project.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * @ClassName OrderMapper
 * @Description TODO 订单后台接口
 * @Author lzy
 * @Date 2023/4/3 10:07
 **/
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    
    /**
    * @Description 根据订单编号删除订单
    * @Author lzy
    * @Date 2023/4/13 13:01
    * @Return void
    * @param orderNumber
    */
    @Delete("delete from orders where order_number = #{orderNumber}")
    Integer deleteByOrderNumber(String orderNumber);

    /**
    * @Description 支付完成修改订单为 已支付
    * @Author lzy
    * @Date 2023/4/13 13:04
    * @Return void
    * @param orderNumber
    */
    @Update("update orders set status_id = 2, pay_time = now() where order_number = #{orderNumber}")
    void updateOrderStatus(String orderNumber);

    @Update("update orders set status_id = #{status} where id = #{orderId}")
    int updateOrderStatusByOrderId(@Param("orderId") Integer orderId,@Param("status")int status);
//    @Select("select * from orders")
//    @Results({
//            @Result(column = "id", property = "id")
//    })
//    List<Order> getMyAllOrder();
}
